<template>
	<view class="index-main">
	   <view style="background-color: #ffffff;padding-bottom: 5px;">
		<view style="padding-left: 10px;padding-right: 10px;">
			<u-search placeholder="输入关键词搜索中标" :show-action="false" :clearabled="true" v-model="keyword" @search="searchList"></u-search>
		</view>
	   	<!-- <u-tabs :list="list1"  itemStyle="width: 50%; height: 34px;"   @click="click"></u-tabs> -->
	<!-- 	<dropdown :menuTop="88" :filterData="filterData"
			:updateMenuName="true"  @confirm="confirm"  dataFormat="Object"></dropdown> -->
	   </view>
	   <view style="margin-top: 5px;">
		   <view v-if="zbList.length" @click="goZbDetail(item)" class="display_flex display-flex-column zb-block" v-for="(item, index) in zbList" :key="index">
		   	<view class="zb-title">
		   		{{item.xiangmumingcheng}}
		   	</view>
			<view style="margin: 8px 0;">
				<text style="color: #afafaf;">招标单位：</text><text>{{item.zhaobiaodanwei}}</text>
			</view>
			<view style="margin: 8px 0;">
				<text style="color: #afafaf;">项目金额：</text><text>{{item.toubiaojiage}}元</text>
			</view>
			<view class="display-flex ">
				<view class="zbgg-t">
					中标公告
				</view>
				<view style="margin-left: auto;color: #afafaf;">
					{{$date.toTimeText(item.fabushijian,true)}}
				</view>
			</view>
		   </view>
		   <view style="margin-top: 100px;" v-if="!zbList.length" >
		   	  <u-empty mode='list'></u-empty>
		   </view>
		   
			<view style="margin-top: 20px;padding-bottom: 20px;" v-if="dataLoading==false && zbList.length">
				<u-loadmore
						status="nomore" 
						nomore-text="没有更多了" 
					/>
			</view>
	   </view>
		
	</view>
</template>

<script>
	import {mapGetters} from 'vuex';
	import { toLogin} from '@/libs/login.js';
	import { zhongbiaogonggaoList, zhaobiaofenleiList} from '@/api/api.js';
	import {dropdown} from '@/components/dropdown/index.vue';
export default {
	computed: mapGetters(['isLogin', 'uid']),
	
	components:{
		dropdown
	},
	data() {
		return {
			zbList: [],
			current: 0,
			list1: [{ 
				name: '最新招标',
			}, {
				name: '最新中标',
			}],
			keyword: '',
			menu: [{ 
				name: '招标分类',
			}, {
				name: '发布时间',
			}],
			showPage: -1,
			isToggleing: false,
			filterData: [
				{
					"name":'招标分类',
					"type": 'radio',
					"submenu": [{
							"name": "",
							"submenu": [{
									"name": "满减活动",
									"value": "满减活动"
								},
								{
									"name": "打折优惠",
									"value": "打折优惠"
								},
								{
									"name": "会员专享",
									"value": "会员专享"
								}
							]
						},	
					]
				},
				{
					"name":'发布时间',
					"type": 'time',
				
				}
				
			],
			searchForm:{
				page: 1,
				limit: 6,
				sort: 'fabushijian',
				order: 'desc',
				xiangmumingcheng: ''
			
			},
			dataLoading: true,
			keyword: ''
			
		};
	},
	onShow() {
		// console.log(this.isLogin)
		// this.getFenlei()
	},
	onReady() {

		
	},

	onLoad() {
		this.init()
		
		
	},
	onReachBottom(){
		this.getList();
	},
	methods: {
	
	    goZbDetail(item){
			uni.navigateTo({
				url: '/pages/su_detail/index?id='+item.id
			})
		},
		confirm(e) {
			// this.indexArr = e.index;
			// this.valueArr = e.value;
		console.log(11,e)
		},
		click(item) {
			console.log('item', item);
		},
		leftClick(){
			this.init()
		},
		gologin(){
			toLogin()
		},
		goDetail(item){
			if(!item.lineId){
				this.$u.toast('参数错误')
				this.init()
				return
			}

			uni.navigateTo({
				url:'/pages/driver_map/index?lineId='+item.lineId+'&lineDriverId='+item.lineDriverId
			})
			
		},
		getFenlei(){
			zhaobiaofenleiList().then(res => {
				var list = res.data.list;
				var subList = []
				if(list.length){
					list.forEach(function(item){
						subList.push({
							name: item.zhaobiaofenlei,
							value: item.zhaobiaofenlei
						})
					})
				}
				this.filterData[0]['submenu'][0]['submenu'] = subList
				console.log("this.filterData",this.filterData)
				uni.hideLoading()
			}).catch(err => {
				this.$u.toast(err.msg)
				uni.hideLoading()
			})
		},
		searchList(){
			console.log(111)
			this.searchForm.page = 1;
			this.zbList = []
			this.dataLoading = true;
			this.getList();
		},
		getList(){
			var that = this;
			if(that.dataLoading == false) return
			if(!this.keyword) delete this.searchForm.xiangmumingcheng; 
			else this.searchForm.xiangmumingcheng = '%'+this.keyword+'%'
			zhongbiaogonggaoList(this.searchForm).then(res => {
				uni.hideLoading()
				
				var items = res.data.list
				if(items.length > 0){
					items.forEach(function(t){
						 that.zbList.push(t)
					})
				}
				if(items.length < that.searchForm.limit){
					that.dataLoading = false
					return
				}
				that.searchForm.page++
			}).catch(err => {
				console.log(11,err)
				that.$u.toast(err.msg)
				uni.hideLoading()
			})
		},
		init(){
			var that = this;
			uni.showLoading({
				title: '加载中'
			});
			
			this.getList();
		}
	}
};
</script>

<style lang="scss" >
	page{
		background-color: #f7f7f7 !important;
	}
	
	.zb-block{
		background-color: #ffffff;
		padding: 10px;
		margin: 5px 10px 0 10px;
	}
	.zbgg-t{
		background: #f3f0ec;
		padding: 2px 4px;
		border-radius: 2px;
		color: #ff7b3c;
	}
	
</style>
